#
#  RefObject (http://code.google.com/p/refobject/)
#  Copyright (C) 2010-2011 MIURA Shirow (sharow)
#
require 'erb'

template_c = open("RefNumerics.c.template", "r").read()
template_h = open("RefNumerics.h.template", "r").read()
template_h_internal = open("RefNumericsInternal.h.template", "r").read()

def int_binding
    numericName = "Int"
    typeName = "int"
    binding
end

def uint_binding
    numericName = "UInt"
    typeName = "unsigned int"
    binding
end

def long_binding
    numericName = "Long"
    typeName = "long"
    binding
end

def ulong_binding
    numericName = "ULong"
    typeName = "unsigned long"
    binding
end

# todo
# long long

def float_binding
    numericName = "Float"
    typeName = "float"
    binding
end

def double_binding
    numericName = "Double"
    typeName = "double"
    binding
end


# dirty...
f = open("RefInt.c", "w")
f.write(ERB.new(template_c).result(int_binding))
f = open("RefIntInternal.h", "w")
f.write(ERB.new(template_h_internal).result(int_binding))
f = open("../include/RefObject/RefInt.h", "w")
f.write(ERB.new(template_h).result(int_binding))

f = open("RefUInt.c", "w")
f.write(ERB.new(template_c).result(uint_binding))
f = open("RefUIntInternal.h", "w")
f.write(ERB.new(template_h_internal).result(uint_binding))
f = open("../include/RefObject/RefUInt.h", "w")
f.write(ERB.new(template_h).result(uint_binding))

f = open("RefLong.c", "w")
f.write(ERB.new(template_c).result(long_binding))
f = open("RefLongInternal.h", "w")
f.write(ERB.new(template_h_internal).result(long_binding))
f = open("../include/RefObject/RefLong.h", "w")
f.write(ERB.new(template_h).result(long_binding))

f = open("RefULong.c", "w")
f.write(ERB.new(template_c).result(ulong_binding))
f = open("RefULongInternal.h", "w")
f.write(ERB.new(template_h_internal).result(ulong_binding))
f = open("../include/RefObject/RefULong.h", "w")
f.write(ERB.new(template_h).result(ulong_binding))

f = open("RefFloat.c", "w")
f.write(ERB.new(template_c).result(float_binding))
f = open("RefFloatInternal.h", "w")
f.write(ERB.new(template_h_internal).result(float_binding))
f = open("../include/RefObject/RefFloat.h", "w")
f.write(ERB.new(template_h).result(float_binding))

f = open("RefDouble.c", "w")
f.write(ERB.new(template_c).result(double_binding))
f = open("RefDoubleInternal.h", "w")
f.write(ERB.new(template_h_internal).result(double_binding))
f = open("../include/RefObject/RefDouble.h", "w")
f.write(ERB.new(template_h).result(double_binding))
